package com.hxtrip.zero.demo.controller;

import com.hxtrip.zero.common.res.R;
import com.hxtrip.zero.demo.po.Student;
import com.hxtrip.zero.demo.service.StudentService;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 测试表 前端控制器
 * </p>
 *
 * @author Hireek
 * @since 2022-04-08
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/student")
@Log4j2
public class StudentController {

    private final StudentService studentService;

    /**
     * 通过ID查询
     *
     * @param id ID
     * @return Student
     */
    @GetMapping("/{id}")
    public R<Student> getById(@PathVariable Integer id) {
        log.info("打印日志啦");
        return R.ok(studentService.getById(id));
    }
}
